home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / asm.arc / DOS.MAC < prev    next >
Text File  |  1988-11-20  |  12KB  |  640 lines

  1. ;
  2. ;                DOS Macros
  3. ;
  4. ;    These macros define the interfaces to DOS.  This aids in making calls
  5. ; to DOS from other assembly language routines.  These macros provide the
  6. ; complete interface to the particular DOS function.
  7. ;
  8. ;
  9. ;            LOADREG
  10. ;
  11. ;    This macro is an "inner" macro for use by the DOS interface macros. It
  12. ; allows the caller of a macro to specify a register or a literal value as the
  13. ; parameter to the macro.  This macro loads the correct register specified by
  14. ; the macro with the literal value or from the register specified.  It will
  15. ; also not generate any code if the register that was passed to the calling
  16. ; macro was where that macro wanted the value.
  17. ;
  18. loadreg     macro        destreg,source
  19.         ifdif        <destreg>,<source>
  20.         mov        destreg,source
  21.         endif
  22.         endm
  23. ;
  24. ;            LDROFF
  25. ;
  26. ;    This macro is an "inner" macro for use by the DOS interface macros.  It
  27. ; allows the caller of a macro to specify a register or a literal value as the
  28. ; parameter to the macro.  This macro loads the correct register specified by
  29. ; the macro with the offset of a particular memory location.  Or it will load
  30. ; the correct register from another register, depending on what the user had
  31. ; coded on the original macro.    This macro will not generate any code if the
  32. ; register that was passed to the calling macro was where that macro wanted the
  33. ; value.
  34. ;
  35. ldroff        macro        destreg,source,src2
  36.         ifdif        <destreg>,<source>
  37.         ifidn        <source>,<offset>
  38.         lea        destreg,src2
  39.         else
  40.         loadreg     destreg,source
  41.         endif
  42.         endif
  43.         endm
  44. ;
  45. dosfn        macro        fncnum
  46.         mov        ah,fncnum
  47.         int        21h
  48.         endm
  49. ;
  50. ;            TERMINATE
  51. ;
  52. ;    This macro issues a 'program terminate' interrupt to DOS.  It will
  53. ; cause the currently executing program to return to DOS.  This is the normal
  54. ; way to exit from DOS.
  55. ;
  56. terminate    macro
  57.         int        20h
  58.         endm
  59. ;
  60. ;            ABSDSKRD
  61. ;
  62. ;    This macro performs an 'absolute disk read' interrupt to DOS.  It will
  63. ; read the specified number of sectors from diskette.  The data will be read
  64. ; into the data area that the user specifies.
  65. ;
  66. absdskrd    macro        drive,numsectrs,lrecnum,transoff
  67.         loadreg     al,drive
  68.         loadreg     cx,numsectrs
  69.         loadreg     dx,lrecnum
  70.         ldroff        bx,transoff
  71.         int        25h
  72.         pop        bx
  73.         endm
  74. ;
  75. ;            ABSDSKWR
  76. ;
  77. ;    This macro performs an 'absolute disk write' interrupt to DOS.  It will
  78. ; write the specified number of sectors to diskette.  The data will be written
  79. ; from the data area that the user specifies.
  80. ;
  81. absdskwr    macro        drive,numsectrs,lrecnum,transoff
  82.         loadreg     al,drive
  83.         loadreg     cx,numsectrs
  84.         loadreg     dx,lrecnum
  85.         ldroff        bx,transoff
  86.         int        26h
  87.         pop        bx
  88.         endm
  89. ;
  90. ;            STAYRES
  91. ;
  92. ;    This macro performs a 'terminate but stay resident' interrupt to DOS.
  93. ; It will cause the caller to return to DOS but the space for the program will
  94. ; remain allocated.
  95. ;
  96. stayres     macro        endaddr
  97.         ldroff        dx,endaddr
  98.         int        27h
  99.         endm
  100. ;
  101. ;            KBDIN
  102. ;
  103. ;    This macro requests a character from the keyboard.  The character is
  104. ; echoed on the CRT.
  105. ;
  106. kbdin        macro
  107.         dosfn        1
  108.         endm
  109. ;
  110. ;            DSPOUT
  111. ;
  112. ;    This macro outputs a character to the CRT.
  113. ;
  114. dspout        macro        outchr
  115.         loadreg     dl,outchr
  116.         dosfn        2
  117.         endm
  118. ;
  119. ;            AUXIN
  120. ;
  121. ;    This macro inputs a character from the auxilary input device.
  122. ;
  123. auxin        macro
  124.         dosfn        3
  125.         endm
  126. ;
  127. ;            AUXOUT
  128. ;
  129. ;    This macro outputs a character to the auxilary output device.
  130. ;
  131. auxout        macro        outchr
  132.         loadreg     dl,outchr
  133.         dosfn        4
  134.         endm
  135. ;
  136. ;            PRNOUT
  137. ;
  138. ;    This macro outputs a character to the first printer.
  139. ;
  140. prnout        macro        outchr
  141.         loadreg     dl,outchr
  142.         dosfn        5
  143.         endm
  144. ;
  145. ;            CONSIO
  146. ;
  147. ;
  148. ;    This macro issues a 'direct console I/O' interrupt to DOS.  If no
  149. ; argument is supplied to this macro, console input will be performed.
  150. ; otherwise console output will be performed.
  151. ;
  152. consio        macro        outchr
  153.         ifb        <outchr>
  154.         mov        dl,0ffh
  155.         else
  156.         loadreg     dl,outchr
  157.         endif
  158.         dosfn        6
  159.         endm
  160. ;
  161. ;            CONIONE
  162. ;
  163. ;    This macro issues a 'direct console I/O with no echo' interrupt to DOS.
  164. ; If no argument is supplied to this macro, console input will be performed, the
  165. ; character input from the keyboard will not be echoed.  Otherwise console
  166. ; output will be performed.
  167. ;
  168. conione     macro        outchr
  169.         ifb        <outchr>
  170.         mov        dl,0ffh
  171.         else
  172.         loadreg     dl,outchr
  173.         endif
  174.         dosfn        7
  175.         endm
  176. ;
  177. ;            KBDINE
  178. ;
  179. ;    This macro gets a character from the keyboard and returns it.  The
  180. ; character is not echoed on the screen.
  181. ;
  182. kbdine        macro
  183.         dosfn        8
  184.         endm
  185. ;
  186. ;            PRNSTR
  187. ;
  188. ;    This macro will issue a 'print string' interrupt to DOS.  It will print
  189. ; the string whose offset is passed to the macro.  It is assumed that DS
  190. ; contains the segment value for the string.  The string must terminate with
  191. ; a '$' character.
  192. ;
  193. prnstr        macro        p1,p2
  194.         ldroff        dx,p1,p2
  195.         dosfn        9
  196.         endm
  197. ;
  198. ;            BKBDIN
  199. ;
  200. ;    This macro will issue a 'buffered keyboard input' interrupt to DOS.
  201. ; The offset of where the buffer is located is passed to the macro.  It is
  202. ; assumed that DS constains the segment which contains the buffer.  The first
  203. ; byte of the buffer must be the length of the buffer - 2.  The second byte is
  204. ; filled in and contains the number of characters read in.  The characters read
  205. ; in are placed starting at the third byte of the buffer.
  206. ;
  207. bkbdin        macro        p1,p2
  208.         ldroff        dx,p1,p2
  209.         dosfn        0ah
  210.         endm
  211. ;
  212. ;            CHKBDST
  213. ;
  214. ;    This macro will issue a 'check keyboard status' interrupt to DOS.  The
  215. ; result is that upon return AL will contain 0FFH if there is a character
  216. ; available at the keyboard, otherwise it will contain 00H.
  217. ;
  218. chkbdst     macro
  219.         dosfn        0bh
  220.         endm
  221. ;
  222. ;            CKBIKF
  223. ;
  224. ;    This macro will issue a 'clear keyboard buffer and invoke keyboard
  225. ; function' interrupt to DOS.  Forces system to wait until a character is
  226. ; actually typed.
  227. ;
  228. ckbikf        macro
  229.         dosfn        0ch
  230.         endm
  231. ;
  232. ;            DSKRSET
  233. ;
  234. ;    This macro will issue a disk reset interrupt to DOS.
  235. ;
  236. dskrset     macro
  237.         dosfn        0dh
  238.         endm
  239. ;
  240. ;            SELDSK
  241. ;
  242. ;    This macro will issue a select disk interrupt to DOS.  The drive
  243. ; specified will become the defualt drive.
  244. ;
  245. seldsk        macro        drive
  246.         ldreg        al,drive
  247.         dosfn        0eh
  248.         endm
  249. ;
  250. ;            FCBOPEN
  251. ;
  252. ;    This macro will issue an open file interrupt to DOS.
  253. ;
  254. fcbopen     macro        p1,p2
  255.         ldroff        dx,p1,p2
  256.         dosfn        0fh
  257.         endm
  258. ;
  259. ;            FCBCLOSE
  260. ;
  261. ;    This macro will issue a close file interrupt to DOS.
  262. ;
  263. fcbclose    macro        p1,p2
  264.         ldroff        dx,p1,p2
  265.         dosfn        10h
  266.         endm
  267. ;
  268. ;            FCBSRCH1
  269. ;
  270. ;    This macro will issue a search for first entry interrupt to DOS.
  271. ;
  272. fcbsrch1    macro        p1,p2
  273.         ldroff        dx,p1,p2
  274.         dosfn        11h
  275.         endm
  276. ;
  277. ;            FCBSRCHN
  278. ;
  279. ;    This macro will issue a search for next entry interrupt to DOS.
  280. ;
  281. fcbsrchn    macro        p1,p2
  282.         ldroff        dx,p1,p2
  283.         dosfn        12h
  284.         endm
  285. ;
  286. ;            FCBDEL
  287. ;
  288. ;    This macro will issue a delete file interrupt to DOS.
  289. ;
  290. fcbdel        macro        p1,p2
  291.         ldroff        dx,p1,p2
  292.         dosfn        13h
  293.         endm
  294. ;
  295. ;            FCBSEQRD
  296. ;
  297. ;    This macro will issue a sequential read interrupt to DOS.
  298. ;
  299. fcbseqrd    macro        p1,p2
  300.         ldroff        dx,p1,p2
  301.         dosfn        14h
  302.         endm
  303. ;
  304. ;            FCBSEQWR
  305. ;
  306. ;    This macro will issue a sequential write interrupt to DOS.
  307. ;
  308. fcbseqwr    macro        p1,p2
  309.         ldroff        dx,p1,p2
  310.         dosfn        15h
  311.         endm
  312. ;
  313. ;            FCBCRE
  314. ;
  315. ;    This macro will issue a file create interrupt to DOS.
  316. ;
  317. fcbcre        macro        p1,p2
  318.         ldroff        dx,p1,p2
  319.         dosfn        16h
  320.         endm
  321. ;
  322. ;            FCBRENAME
  323. ;
  324. ;    This macro will issue a file rename interrupt to DOS.
  325. ;
  326. fcbrename    macro        p1,p2
  327.         ldroff        dx,p1,p2
  328.         dosfn        17h
  329.         endm
  330. ;
  331. curdsk        macro
  332.         dosfn        19h
  333.         endm
  334. ;
  335. setdta        macro        p1,p2
  336.         ldroff        dx,p1,p2
  337.         dosfn        1ah
  338.         endm
  339. ;
  340. getfat        macro
  341.         dosfn        1bh
  342.         endm
  343. ;
  344. getsfat     macro        drive
  345.         loadreg     dl,drive
  346.         dosfn        1ch
  347.         endm
  348. ;
  349. rndrd        macro        p1,p2
  350.         ldroff        dx,p1,p2
  351.         dosfn        21h
  352.         endm
  353. ;
  354. rndwr        macro        p1,p2
  355.         ldroff        dx,p1,p2
  356.         dosfn        22h
  357.         endm
  358. ;
  359. fcbsize     macro        p1,p2
  360.         ldroff        dx,p1,p2
  361.         dosfn        23h
  362.         endm
  363. ;
  364. setrrfld    macro        p1,p2
  365.         ldroff        dx,p1,p2
  366.         dosfn        24h
  367.         endm
  368. ;
  369. setivec     macro        ivec,p1,p2
  370.         loadreg     al,ivec
  371.         ldroff        dx,p1,p2
  372.         dosfn        25h
  373.         endm
  374. ;
  375. crepsp        macro        p1,p2
  376.         ldroff        dx,p1,p2
  377.         dosfn        26h
  378.         endm
  379. ;
  380. rblkrd        macro        cnt,p1,p2
  381.         loadreg     cx,cnt
  382.         ldroff        dx,p1,p2
  383.         dosfn        27h
  384.         endm
  385. ;
  386. rblkwr        macro        cnt,p1,p2
  387.         loadreg     cx,cnt
  388.         ldroff        dx,p1,p2
  389.         dosfn        28h
  390.         endm
  391. ;
  392. prsfn        macro        p1,p2,p3,p4
  393.         ldroff        si,p1,p2
  394.         ifidn        <p1>,<offset>
  395.         ldroff        di,p3,p4
  396.         else
  397.         ldroff        di,p2,p3
  398.         endif
  399.         dosfn        29h
  400.         endm
  401. ;
  402. getdate     macro
  403.         dosfn        2ah
  404.         endm
  405. ;
  406. setdate     macro
  407.         dosfn        2bh
  408.         endm
  409. ;
  410. gettime     macro
  411.         dosfn        2ch
  412.         endm
  413. ;
  414. settime     macro
  415.         dosfn        2dh
  416.         endm
  417. ;
  418. srverify    macro        verify
  419.         loadreg     al,verify
  420.         sub        dl,dl
  421.         dosfn        2eh
  422.         endm
  423. ;
  424. setverify    macro
  425.         srverify    1
  426.         endm
  427. ;
  428. resetverify    macro
  429.         srverify    0
  430.         endm
  431. ;
  432. getdta        macro
  433.         dosfn        2fh
  434.         endm
  435. ;
  436. getvernm    macro
  437.         dosfn        30h
  438.         endm
  439. ;
  440. keep        macro        rc,size
  441.         loadreg     al,rc
  442.         loadreg     dx,size
  443.         dosfn        31h
  444.         endm
  445. ;
  446. cbchk        macro        setflg,stateflg
  447.         loadreg     al,setflg
  448.         loadreg     dl,stateflg
  449.         dosfn        33h
  450.         endm
  451. ;
  452. getivec     macro        vecnum
  453.         loadreg     al,vecnum
  454.         dosfn        35h
  455.         endm
  456. ;
  457. gdfreesp    macro        drive
  458.         loadreg     dl,drive
  459.         dosfn        36h
  460.         endm
  461. ;
  462. cntrydep    macro        p1,p2
  463.         ldroff        dx,p1,p2
  464.         sub        al,al
  465.         dosfn        38h
  466.         endm
  467. ;
  468. mkdir        macro        p1,p2
  469.         ldroff        dx,p1,p2
  470.         dosfn        39h
  471.         endm
  472. ;
  473. rmdir        macro        p1,p2
  474.         ldroff        dx,p1,p2
  475.         dosfn        3ah
  476.         endm
  477. ;
  478. chdir        macro        p1,p2
  479.         ldroff        dx,p1,p2
  480.         dosfn        3bh
  481.         endm
  482. ;
  483. creat        macro        acc,p1,p2
  484.         loadreg     cx,acc
  485.         ldroff        dx,p1,p2
  486.         dosfn        3ch
  487.         endm
  488. ;
  489. openfile    macro        access,p1,p2
  490.         loadreg     al,access
  491.         ldroff        dx,p1,p2
  492.         dosfn        3dh
  493.         endm
  494. ;
  495. open        macro        access,p1,p2
  496.         ifidn        <access>,<r>
  497.         openfile    0,p1,p2
  498.         else
  499.         ifidn        <access>,<w>
  500.         openfile    1,p1,p2
  501.         else
  502.         ifidn        <access>,<u>
  503.         openfile    2,p1,p2
  504.         endif
  505.         endif
  506.         endif
  507.         endm
  508. ;
  509. close        macro        file
  510.         loadreg     bx,file
  511.         dosfn        3eh
  512.         endm
  513. ;
  514. read        macro        file,numbytes,p1,p2
  515.         loadreg     bx,file
  516.         loadreg     cx,numbytes
  517.         ldroff        dx,p1,p2
  518.         dosfn        3fh
  519.         endm
  520. ;
  521. write        macro        file,numbytes,p1,p2
  522.         loadreg     bx,file
  523.         loadreg     cx,numbytes
  524.         ldroff        dx,p1,p2
  525.         dosfn        40h
  526.         endm
  527. ;
  528. unlink        macro        p1,p2
  529.         ldroff        dx,p1,p2
  530.         dosfn        41h
  531.         endm
  532. ;
  533. lseek        macro        file,mode,hipos,lopos
  534.         loadreg     bx,file
  535.         loadreg     al,mode
  536.         loadreg     cx,hipos
  537.         loadreg     dx,lopos
  538.         dosfn        42h
  539.         endm
  540. ;
  541. chmod        macro        mode,attr,p1,p2
  542.         loadreg     al,mode
  543.         loadreg     cx,attr
  544.         ldroff        dx,p1,p2
  545.         dosfn        43h
  546.         endm
  547. ;
  548. ioctl        macro        fc,file
  549.         loadreg     al,fc
  550.         loadreg     bx,file
  551.         dosfn        44h
  552.         endm
  553. ;
  554. dup        macro        file
  555.         loadreg     bx,file
  556.         dosfn        45h
  557.         endm
  558. ;
  559. fdup        macro        file1,file2
  560.         loadreg     bx,file1
  561.         loadreg     cx,file2
  562.         dosfn        46h
  563.         endm
  564. ;
  565. gcurdir     macro        drive,p1,p2
  566.         loadreg     dl,drive
  567.         ldroff        si,p1,p2
  568.         dosfn        47h
  569.         endm
  570. ;
  571. alloc        macro        size
  572.         loadreg     bx,size
  573.         dosfn        48h
  574.         endm
  575. ;
  576. free        macro        ptr
  577.         loadreg     es,ptr
  578.         dosfn        49h
  579.         endm
  580. ;
  581. setblock    macro        ptr,size
  582.         loadreg     es,ptr
  583.         loadreg     bx,size
  584.         dosfn        4ah
  585.         endm
  586. ;
  587. exec        macro        fc,p1,p2,p3,p4
  588.         ldroff        dx,p1,p2
  589.         ifidn        <p1>,<offset>
  590.         ldroff        bx,p3,p4
  591.         else
  592.         ldroff        bx,p2,p3
  593.         endif
  594.         loadreg     al,fc
  595.         dosfn        4bh
  596.         endm
  597. ;
  598. exit        macro        rc
  599.         loadreg     al,rc
  600.         dosfn        4ch
  601.         endm
  602. ;
  603. wait        macro
  604.         dosfn        4dh
  605.         endm
  606. ;
  607. fndfile1    macro        attr,p1,p2
  608.         loadreg     cx,attr
  609.         ldroff        dx,p1,p2
  610.         dosfn        4eh
  611.         endm
  612. ;
  613. fndfilen    macro
  614.         dosfn        4fh
  615.         endm
  616. ;
  617. rename        macro        p1,p2,p3,p4
  618.         ldroff        dx,p1,p2
  619.         ifidn        <p1>,<offset>
  620.         ldroff        di,p3,p4
  621.         else
  622.         ldroff        di,p2,p3
  623.         endif
  624.         dosfn        56h
  625.         endm
  626. ;
  627. getftime    macro        file
  628.         loadreg     bx,file
  629.         sub        al,al
  630.         dosfn        57h
  631.         endm
  632. ;
  633. setftime    macro        file,date,time
  634.         loadreg     bx,file
  635.         loadreg     dx,date
  636.         loadreg     cx,time
  637.         mov        al,1
  638.         dosfn        57h
  639.         endm
  640.